package com.ruoyi.carShopService.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.carShopService.domain.MessageY;
import com.ruoyi.system.api.domain.Message;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;

import com.ruoyi.carShopService.service.IMessageService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;

/**
 * 活动（信息）发布Controller
 *
 * @author ruoyi
 * @date 2024-09-12
 */
@RestController
@RequestMapping("/message")
public class MessageController extends BaseController
{
    @Autowired
    private IMessageService MessageService;


    /**
     * 查询活动（信息）发布列表
     */
//    @RequiresPermissions("carShopService:MessageY:list")
    @GetMapping("/list")
    public TableDataInfo list(MessageY message)
    {
        System.out.println("carShopService/message1/list启动");
        startPage();
        List<com.ruoyi.carShopService.domain.MessageY> list = MessageService.selectMessageListSJ(message);
        //return client.list(message);
        return getDataTable(list);
    }

    /**
     * 导出活动（信息）发布列表
     */
    //@RequiresPermissions("carShopService:Message:export")
    @Log(title = "活动（信息）发布", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MessageY message)
    {
        List<com.ruoyi.carShopService.domain.MessageY> list = MessageService.selectMessageListSJ(message);
        ExcelUtil<com.ruoyi.carShopService.domain.MessageY> util = new ExcelUtil<com.ruoyi.carShopService.domain.MessageY>(com.ruoyi.carShopService.domain.MessageY.class);
        util.exportExcel(response, list, "活动（信息）发布数据");
    }

    /**
     * 获取活动（信息）发布详细信息
     */
    //@RequiresPermissions("carShopService:Message:query")
    @GetMapping(value = "/{mesId}")
    public AjaxResult getInfo(@PathVariable("mesId") Long mesId)
    {
        return success(MessageService.selectMessageByMesId(mesId));
    }

    /**
     * 新增活动（信息）发布
     */
    //@RequiresPermissions("carShopService:Message:add")
    @Log(title = "活动（信息）发布", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MessageY message)
    {
        return toAjax(MessageService.insertMessage(message));
    }

    /**
     * 修改活动（信息）发布
     */
    //@RequiresPermissions("carShopService:Message:edit")
    @Log(title = "活动（信息）发布", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MessageY message)
    {
        return toAjax(MessageService.updateMessage(message));
    }

    /**
     * 删除活动（信息）发布
     */
    //@RequiresPermissions("carShopService:Message:remove")
    @Log(title = "活动（信息）发布", businessType = BusinessType.DELETE)
	@DeleteMapping("/{mesIds}")
    public AjaxResult remove(@PathVariable Long[] mesIds)
    {
        System.out.println("执行删除");
        return toAjax(MessageService.deleteMessageByMesIds(mesIds));
    }
}
